# @shuaige : 陈世玉
# @name :07获取百度网站的文字.py
# @time :2024/12/4 19:34
from lxml import etree
import requests
url='http://ww.baidu.com'
headers={
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
}
response=requests.get(url,headers=headers)
tree=etree.HTML(response.text)
print(tree)
#解析网络源码，获得想要的数据
#xpath的返回值是一个列表
value=tree.xpath('//input[@id="su"]/@value')
print(value[0])
